using System;
using System.Linq;
using System.Collections.Generic;
using DevExpress.CodeRush.StructuralParser;

namespace CR.StyleCop.Naming {

    public class ConstFieldNamesMustBeginWithUpperCaseLetterSearcher : BaseStyleCopIssueSearcher<IFieldElement> {

        public override IEnumerable<StyleCopIssue> FindIssues(IEnumerable<IFieldElement> elements) {
            var issues = elements.Where(f => f.IsConst)
                .Where(f => char.IsLower(f.Name[0]) || !char.IsLetter(f.Name[0]));

            return issues.Select(e => new StyleCopIssue {
                Element = e,
                IssueDescription = Resource.ConstFieldNamesMustBeginWithUpperCaseLetterSearcherIssueDescription
            });
        }
    }
}